/**
 * Auto gen via dbpojo-gen.
 */
package com.us.usws.dao;

import java.util.List;

import net.iwsh.core.db.DBExecutor;
import net.iwsh.core.db.ext.DialectSyntaxParser;
import net.iwsh.core.db.ext.SQLWithParams;
import net.iwsh.core.utils.IDGenerator;

import com.us.usws.model.domain.base.BaseVideoTypeExtattr;
import com.us.usws.model.domain.base.VideoTypeExtattr;
import com.us.usws.model.flat.base.DOBaseVideoTypeExtattr;

/**
 * DAO class
 * @author robot
 */
public class BaseVideoTypeExtattrDAO {

	/**
	 * Query SQLs
	 */
	private static final String SQL_GET_TOTAL_COUNT = "select count(*) from hvb_video_type_extattr";

	private static final String SQL_GET_ALL_BASEVIDEOTYPEEXTATTRS = "select * from hvb_video_type_extattr order by video_type_dsid";

	private static final String SQL_GET_BASEVIDEOTYPEEXTATTR_BY_PK = "select * from hvb_video_type_extattr where uid = ?";

	/**
	 * CUR SQLs
	 */
	private static final String SQL_INSERT_BASEVIDEOTYPEEXTATTR = "insert into hvb_video_type_extattr(uid,video_type_dsid,seq_num,label,code,data_type,data_len,is_null,default_value,input_type,value_options,css,hint,is_ep_enable,show_prefix,show_suffix,create_by_uid,create_date,last_upd_by_uid,last_upd_date) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

	private static final String SQL_UPDATE_BASEVIDEOTYPEEXTATTR = "update hvb_video_type_extattr set video_type_dsid=?, seq_num=?, label=?, code=?, data_type=?, data_len=?, is_null=?, default_value=?, input_type=?, value_options=?, css=?, hint=?, is_ep_enable=?, show_prefix=?, show_suffix=?, create_by_uid=?, create_date=?, last_upd_by_uid=?, last_upd_date=? where uid=?";

	private static final String SQL_DEL_BASEVIDEOTYPEEXTATTR = "delete from hvb_video_type_extattr where uid=?";

	/**
	 * DBExeutor
	 */
	private DBExecutor dbe = new DBExecutor();

	/**
	 * Get Count.
	 */
	public int getTotalCount() {
		return dbe.getCount(SQL_GET_TOTAL_COUNT);
	}

	/**
	 * Get all list.
	 */
	public List<BaseVideoTypeExtattr> getAllBaseVideoTypeExtattrs() {
		return dbe.list(SQL_GET_ALL_BASEVIDEOTYPEEXTATTRS, BaseVideoTypeExtattr.class);
	}

	/**
	 * get readonly list
	 * @return
	 */
	public List<VideoTypeExtattr> getAllReadonlyVideoTypeExtattrs() {
		return dbe.list(SQL_GET_ALL_BASEVIDEOTYPEEXTATTRS, VideoTypeExtattr.class);
	}

	/**
	 * Get all list by pagination.
	 */
	public List<BaseVideoTypeExtattr> getBaseVideoTypeExtattrs(int start, int end) {
		SQLWithParams swp = DialectSyntaxParser.getParser().getPaginationSQLWithParams(SQL_GET_ALL_BASEVIDEOTYPEEXTATTRS, null, start, end);
		return dbe.list(swp.getSql(), BaseVideoTypeExtattr.class, swp.getParams());
	}

	/**
	 * Get BaseVideoTypeExtattr by primary key.
	 */
	public BaseVideoTypeExtattr getBaseVideoTypeExtattr(String uid) {
		BaseVideoTypeExtattr b = dbe.load(SQL_GET_BASEVIDEOTYPEEXTATTR_BY_PK, BaseVideoTypeExtattr.class, uid);
		return b;
	}

	/**
	 * Insert one row.
	 */
	public String insertBaseVideoTypeExtattr(DOBaseVideoTypeExtattr baseVideoTypeExtattr) {
		String uid = IDGenerator.getInstance().genUID();
		baseVideoTypeExtattr.setUid(uid);
		dbe.execute(SQL_INSERT_BASEVIDEOTYPEEXTATTR, baseVideoTypeExtattr.getUid(), baseVideoTypeExtattr.getVideoTypeDsid(),
				baseVideoTypeExtattr.getSeqNum(), baseVideoTypeExtattr.getLabel(), baseVideoTypeExtattr.getCode(),
				baseVideoTypeExtattr.getDataType(), baseVideoTypeExtattr.getDataLen(), baseVideoTypeExtattr.getIsNull(),
				baseVideoTypeExtattr.getDefaultValue(), baseVideoTypeExtattr.getInputType(), baseVideoTypeExtattr.getValueOptions(),
				baseVideoTypeExtattr.getCss(), baseVideoTypeExtattr.getHint(), baseVideoTypeExtattr.getIsEpEnable(),
				baseVideoTypeExtattr.getShowPrefix(), baseVideoTypeExtattr.getShowSuffix(), baseVideoTypeExtattr.getCreateByUid(),
				baseVideoTypeExtattr.getCreateDate(), baseVideoTypeExtattr.getLastUpdByUid(), baseVideoTypeExtattr.getLastUpdDate());
		return uid;
	}

	/**
	 * Update by PK.
	 */
	public void updateBaseVideoTypeExtattr(DOBaseVideoTypeExtattr baseVideoTypeExtattr) {
		dbe.execute(SQL_UPDATE_BASEVIDEOTYPEEXTATTR, baseVideoTypeExtattr.getVideoTypeDsid(), baseVideoTypeExtattr.getSeqNum(),
				baseVideoTypeExtattr.getLabel(), baseVideoTypeExtattr.getCode(), baseVideoTypeExtattr.getDataType(),
				baseVideoTypeExtattr.getDataLen(), baseVideoTypeExtattr.getIsNull(), baseVideoTypeExtattr.getDefaultValue(),
				baseVideoTypeExtattr.getInputType(), baseVideoTypeExtattr.getValueOptions(), baseVideoTypeExtattr.getCss(),
				baseVideoTypeExtattr.getHint(), baseVideoTypeExtattr.getIsEpEnable(), baseVideoTypeExtattr.getShowPrefix(),
				baseVideoTypeExtattr.getShowSuffix(), baseVideoTypeExtattr.getCreateByUid(), baseVideoTypeExtattr.getCreateDate(),
				baseVideoTypeExtattr.getLastUpdByUid(), baseVideoTypeExtattr.getLastUpdDate(), baseVideoTypeExtattr.getUid());
	}

	/**
	 * Delete row by PK.
	 */
	public void deleteBaseVideoTypeExtattr(String uid) {
		dbe.execute(SQL_DEL_BASEVIDEOTYPEEXTATTR, uid);
	}

}